/*
* @Author: obsidian
* @Date:   2016-03-01 10:18:42
* @Last Modified by:   obsidian
* @Last Modified time: 2016-04-22 09:07:29
*/

#include "menu_gps.h"
#include "../lcd_global.h"
#include "module/GPS/GPS.h"
#include "module/pid/pid.h"
#include "control/GPSpath/GPSpath.h"
#include "../lcd.h"


void  menu_gps_init(void *parg);
struct Item gps_i[MAX_ITEM_NUM] = 
{
    {.ctx = "conv1",    .id = 1, .ctx_len = 5, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&gyro.gyro_convert1,           .func_enter = nop, input,nop,nop},
    {.ctx = "conv2",    .id = 2, .ctx_len = 5, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&gyro.gyro_convert2,           .func_enter = nop, input,nop,nop},
    {.ctx = "effl",     .id = 3, .ctx_len = 4, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&encoder_property[0].convert,  .func_enter = nop, input,nop,nop},
    {.ctx = "effr",     .id = 4, .ctx_len = 5, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&encoder_property[1].convert,  .func_enter = nop, input,nop,nop},
    {.ctx = "direc",    .id = 6, .ctx_len = 5, .flag = FILE, .value_type = INTEGER, .p_value = (void *)&gps.direction,              .func_enter =   nop, input,nop,nop},
    {.ctx = "status",   .id = 7, .ctx_len = 6, .flag = FILE, .value_type = INTEGER, .p_value = (void *)&gps.status,                 .func_enter =   nop, input,nop,nop},
};

struct Node gps_n = 
{
    // .itemnum        =   sizeof(gps_i) / sizeof(gps_i[0]),
    // .page_num       =   sizeof(gps_i) / sizeof(gps_i[0]) / PAGE_SIZE,
    .page_index     =   0, 
    .node_id        =   1, 
    .p_item         =   gps_i,
    .position       =   {0, 0},
    .parent         =   &control_n,
    .child          =   {0},
    .init           =   menu_gps_init,
};

void  menu_gps_init(void *parg)
{
    unsigned char i = 0;
    for(i = 0;i < MAX_ITEM_NUM;i ++)
    {
        if(gps_i[i].ctx[0] == 0){break;}
        gps_n.itemnum ++;
    }
    gps_n.page_num = gps_n.itemnum / PAGE_SIZE;
    gps_n.save = gps.save;
}
